package com.ssplayer.fragment;

import java.util.List;

import android.annotation.SuppressLint;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.ssplayer.activity.R;
import com.ssplayer.activity.VideoPlayerActivity;
import com.ssplayer.adapter.VideoAdapter;
import com.ssplayer.bean.Video;
import com.ssplayer.utils.DownTuUtils;
import com.ssplayer.utils.MediaUtils;

public class VideoFragment extends Fragment implements OnItemClickListener {

	private Context context;
	private List<Video> videos;
	private ListView video_list;
	private VideoAdapter videoAdapter;

	public VideoFragment() {
	}

	public VideoFragment(Context context, List<Video> videos) {

		this.context = context;
		this.videos = videos;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_video, container, false);
		video_list = (ListView) view.findViewById(R.id.video_list);
		videoAdapter = new VideoAdapter(getActivity(), videos);
		video_list.setAdapter(videoAdapter);
		video_list.setOnItemClickListener(this);
		return view;
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		Intent intent = new Intent();
		intent.putExtra("path", videos.get(position).getUrl());
		intent.putExtra("title", videos.get(position).getTitle());
		intent.setClass(context, VideoPlayerActivity.class);
		startActivity(intent);
	}

	
}
